<!DOCTYPE html>
<html lang="en">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<!-- Mirrored from condorthemes.com/cleanzone/pages-login.html by HTTrack Website Copier/3.x [XR&CO'2013], Mon, 31 Mar 2014 14:37:32 GMT -->

<head th:include="css :: css">

</head>

<style>
    .help-inline {
        position: absolute;
        top: 38px;
        left: 2px;
        color: red;
    }

</style>
<body class="texture">

<div id="cl-wrapper" class="login-container">
    <div class="middle-login">
        <div class="block-flat">
            <div class="header">
                <h3 class="text-center" id="loginHeader">
                    <img class="logo-img" th:attr="src=@{/images/logo.png}" alt="logo"/>豆乐卡管理平台</h3>
            </div>
            <div>
                <form style="margin-bottom: 0px !important;" class="form-horizontal" id="loginForm">
                    <div class="content">
                        <div class="form-group">
                            <div class="col-sm-12">
                                <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-user"></i>
                                        </span>
                                    <input type="text" placeholder="请输入用户名"  name="phoneNo"
                                           class="form-control" maxlength="11">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-lock"></i>
                                        </span>
                                    <input type="password" placeholder="请输入密码"  name="loginPwd"
                                           class="form-control" maxlength="12">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="foot">
                        <button class="btn btn-primary" type="button" id="loginBtn">登录</button>
                    </div>
                </form>
            </div>
        </div>
        <div class="text-center out-links">
            <a href="#">&copy; 2020 山东知行数据服务有限公司</a>
        </div>
    </div>
</div>

<div th:include="js :: js"></div>
<script th:attr="src=@{/js/jsencrypt.min.js}"></script>
<script>
    jQuery.validator.addMethod("isNormalPwd", function (value, element) {
        var tel = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/;
        return this.optional(element) || (tel.test(value));
    }, "请输入6-12位字母数字组合");
    jQuery.validator.addMethod("isNormalPhone", function (value, element) {
        var tel = /^1[3|4|5|7|8][0-9]\d{8}$/;
        return this.optional(element) || (tel.test(value));
    }, "请输入正确的手机号");
    $(function () {
        $("#loginForm").validate({
            rules: {
                phoneNo: {
                    required: true,
                    isNormalPhone: true
                },
                loginPwd: {
                    required: true,
//                    isNormalPwd: true
                }
            },
            errorClass: "help-inline",
            errorElement: "p",
            highlight: function (element, errorClass, validClass) {
                $(element).parents('.control-group').addClass('error');
            },
            unhighlight: function (element, errorClass, validClass) {
                $(element).parents('.control-group').removeClass('error');
            }
        });


        $("#loginBtn").click(function () {
            var v = $("#loginForm").valid();
            if (!v) {
                return;
            }
            var obj = $(this);
            var username = $("input[name=phoneNo]").val();
            var password = $("input[name=loginPwd]").val();
            username = $.trim(username);
            password = $.trim(password);

            $("#loginBtn").attr("disabled", "disabled");
            $.ajax({
                    type: "POST",
                    url: "/getPublicKey",
                    data: {},
                    async: false,
                    dataType: "json",
                    success: function (data) {
                        if (data != null) {
                            var str = password + data.random_str;
                            var encrypt = new JSEncrypt();
                            encrypt.setPublicKey(data.public_key);
                            var resetPassword = encrypt.encrypt(str);
                            $.ajax({
                                    type: "POST",
                                    url: "/shiro/signIn",
                                    async: false,
                                    data: {
                                        phoneNo: username,
                                        loginPwd: encodeURIComponent(resetPassword)
                                    },
                                    dataType: "json",
                                    success: function (data) {
                                        obj.removeAttr("disabled");
                                        if (data.errorCode === 200) {
                                            window.location.href = "/";
                                        } else {
                                            $.dialog({
                                                title: '提示!',
                                                content: '用户名或密码错误!',
                                                backgroundDismiss: true
                                            });
                                        }
                                    },
                                    error: function () {
                                        obj.removeAttr("disabled");
                                    }
                                }
                            );
                        } else {
                            $.dialog({
                                title: '提示!',
                                content: '获取公钥失败!',
                                backgroundDismiss: true
                            });
                        }
                    }

                }
            );


        })


    })
</script>
</body>

<!-- Mirrored from condorthemes.com/cleanzone/pages-login.html by HTTrack Website Copier/3.x [XR&CO'2013], Mon, 31 Mar 2014 14:37:32 GMT -->

</html>